package cn.wolfcode.crm.serivce.impl;

import cn.wolfcode.crm.domain.ProductStock;
import cn.wolfcode.crm.domain.ProductStock;
import cn.wolfcode.crm.mapper.ProductStockMapper;
import cn.wolfcode.crm.mapper.ProductStockMapper;
import cn.wolfcode.crm.query.QueryObject;
import cn.wolfcode.crm.serivce.IProductStockService;
import cn.wolfcode.crm.util.PageResult;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.math.BigDecimal;
import java.util.Collections;
import java.util.List;


@Service
public class ProductStockServiceImpl implements IProductStockService {
    @Autowired
    private ProductStockMapper productStockMapper;


    public PageResult query(QueryObject qo) {
            Integer total = productStockMapper.count(qo);
            if (total > 0) {
                List<ProductStock> rows = productStockMapper.query(qo);

                return new PageResult(total,rows);
            }
            return new PageResult(0, Collections.EMPTY_LIST);

    }

    @Override
    public Integer countByStoreNumber(BigDecimal storeNumber) {
        return productStockMapper.countByStoreNumber(storeNumber);
    }
}
